<template>
	<view class="my">
		<view class="my_geren">
			<view class="my_geren_top"></view>
			<view class="my_geren_bottom">
				<view class="my_geren_bottom_left">
					<view class="my_geren_bottom_left_tou">
						<view class="my_geren_bottom_left_tou_left">
							<view class="my_geren_bottom_left_tou_left_a">
								<image :src="myobj.avatar" mode="aspectFit"></image>
							</view>
							<view class="my_geren_bottom_left_tou_left_b" v-if="myobj.applymentStatus==1">已认证</view>
							<view class="my_geren_bottom_left_tou_left_b" v-if="myobj.applymentStatus==0">未认证</view>
							<view class="my_geren_bottom_left_tou_left_b" v-if="myobj.applymentStatus==2">认证失败</view>
						</view>
						<view class="my_geren_bottom_left_tou_right">
							<view class="my_geren_bottom_left_tou_right_shang">
								<view>
									<text>{{myobj.realName}}</text>
									<!-- <icon></icon> -->
								</view>

							</view>
							<view class="my_geren_bottom_left_tou_right_xia">
								<view>
									<text class="text1">{{myobj.masseuseTypeName}}</text>
									<text class="text2">{{myobj.score}}星级</text>
								</view>

								<view class="my_geren_bottom_right_c">在线时间：{{onlineTime}}</view>
							</view>
						</view>
					</view>
					<view class="my_geren_bottom_xia">
						<view style="width: 200rpx;">
							<view class="my_geren_bottom_xia_shang">
								<text class="text1"> {{monthOnlineTime}}</text>
								<text class="text2">小时</text>
							</view>
							<view class="my_geren_bottom_xia_xia">本月累计在线</view>
						</view>
						<view style="margin-right: 40rpx;">
							<view class="my_geren_bottom_xia_shang">
								<text class="text1"> {{orderNum}}</text>
								<text class="text2">单</text>
							</view>
							<view class="my_geren_bottom_xia_xia">今日完成订单</view>
						</view>
					</view>
				</view>

			</view>
		</view>
		<!-- <view class="my_main_zhong" >
			<image src="../../static/imgs/qian2.png"></image>
		</view> -->
		<view class="my_main">
			<view class="my_main_shang">
				<view class="my_main_top">常用功能</view>
				<view class="my_main_bottom">
					<view class="my_main_bottom_a" @click="serviceorder">
						<view>
							<image class="img" src="../../static/images/fwdd.png"></image>
						</view>

						<text class="text">服务订单</text>
					</view>
					<view class="my_main_bottom_a" @click="mywallet">
						<view>
							<image class="img" src="../../static/images/qb.png"></image>
						</view>

						<text class="text">我的钱包</text>
					</view>
					<view class="my_main_bottom_a" @click="mallorders">
						<view>
							<image class="img" src="../../static/images/scdd.png"></image>
						</view>

						<text class="text">商城订单</text>
					</view>
					<view class="my_main_bottom_a box" @click="personaldetails">
						<view>
							<image class="img" src="../../static/images/grxx.png"></image>
						</view>

						<text class="text">个人信息</text>
					</view>
					<view class="my_main_bottom_a box" @click="shippingaddress">
						<view>
							<image class="img" src="../../static/images/shdz.png"></image>
						</view>

						<text class="text">收货地址</text>
					</view>
					<view class="my_main_bottom_a box" @click="aboutus">
						<view>
							<image class="img" src="../../static/images/gywm.png"></image>
						</view>

						<text class="text">关于我们</text>
					</view>
					<view class="my_main_bottom_a box" @click="goset">
						<view>
							<image class="img" src="../../static/images/sz.png"></image>
						</view>

						<text class="text">设置</text>
						<!-- <button  @click="getUserInfo()">授权</button> -->
					</view>

				</view>
			</view>
		</view>

		<!-- <view class="tuichu" @click="retreat">
			退出登录
		</view> -->
	</view>
</template>

<script>
	import onlinetime from '@/pagesA/onlinetime/onlinetime.vue'
	import homeServices from '../../service/homeService'
	export default {
		data() {
			return {
				// right: '',
				// padding: '',
				// top: '',
				// height: '',
				obj1: false,
				obj2: true,
				myobj: {},
				monthOnlineTime: '',
				onlineTime: '',
				orderNum: ''
			}
		},
		onLoad() {
			uni.$on('updateNum', nums => {
				console.log(nums)
				if (nums == true) {
					this.obj1 = true
					this.obj2 = false
				}

			})
			uni.$on('obj', obj => {
				console.log(obj)
				if (obj == null) {
					this.obj1 = false
					this.obj2 = true
				}
			})




		},
		onShow() {
			this.getmy()
			this.getstatus()
		},
		onPullDownRefresh() {
			this.getmy()
		},
		methods: {
			async getmy() {

				let res = await homeServices.getlist()
				console.log(res, 'wwwwwwwwwww')
				this.myobj = res.data
				if (res.status == 200) {
					uni.stopPullDownRefresh()
				}
			},
			async getstatus() {
				let res = await homeServices.getstatus()
				this.monthOnlineTime = res.data.monthOnlineTime
				this.onlineTime = res.data.onlineTime
				this.orderNum = res.data.orderNum
				console.log(res, 'vvvvvvv')
			},
			shippingaddress() {
				uni.navigateTo({
					url: '../../pagesB/shippingaddress/shippingaddress'
				});
			},

			goset(){
				uni.navigateTo({
					url:'/pagesB/getinstall/getinstall'
				})
			},
			getUserInfo() {
				// uni.login({
				// 	provider: 'weixin',
				// 	onlyAuthorize:true,
				// 	success: function(loginRes) {
				// 		console.log(loginRes);
				// 	}
				// });
				let _this = this;
				// 获取服务商信息判断手机端是否安装了app
				uni.getProvider({
					// oauth  代表授权登录
					service: 'oauth',
					success: function(res) {
						// 登录
						uni.login({
							provider: 'weixin',
							success: res => {
								console.log(res);
								uni.showToast({
									title:res.authResult.openid,
									icon:'none'
								})
							},
						});
					},
				});
			},

			aboutus() {
				uni.navigateTo({
					url: '../../pagesB/aboutus/aboutus'
				});
			},
			personaldetails() {
				uni.navigateTo({
					url: `../../pagesB/personaldetails/personaldetails?monthOnlineTime=${this.monthOnlineTime}`
				});
			},
			mywallet() {
				uni.navigateTo({
					url: '../../pagesB/mywallet/mywallet'
				});
			},
			mallorders() {
				uni.navigateTo({
					url: '../../pagesB/mallorders/mallorders'
				});
			},
			serviceorder() {
				uni.navigateTo({
					url: '../../pagesB/serviceorder/serviceorder'
				})
			},
			async retreat() {
				let params = {}
				let res = await homeServices.retreat(params)
				uni.showModal({
					title: '提示',
					content: '确认退出登录吗？',
					confirmText: '确定',
					cancelText: '取消',
					success: function(res) {
						if (res.confirm) {
							console.log('用户点击确定');
							uni.removeStorage({
								key: 'token',
								success: function() {
									console.log('success');
									uni.reLaunch({
										url: '/pages/login/login'
									})
								},

							})
						} else if (res.cancel) {
							return
						}
					}

				})
				// state.token=''

				console.log(res)
			},
		}
	}
</script>

<style lang="scss" scoped>
	@import '@/static/sass/my.scss'
</style>
